package com.lxq.test1709.main02;

import java.util.ArrayList;
import java.util.Scanner;

class Struct {
    private int time;
    private int oper;//1=拿出，0=放回
    private int key;
    private int num;

    public Struct(int time, int oper, int key, int num) {
        this.time = time;
        this.oper = oper;
        this.key = key;
        this.num = num;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public int getOper() {
        return oper;
    }

    public void setOper(int oper) {
        this.oper = oper;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public String toString() {
        return "Struct{" + "time=" + time + ", oper=" + oper + ", key=" + key + ", num=" + num + '}';
    }

    public String compare(Struct struct) {
        if (this.num == struct.num) {
            return "equal";
        }
        if (this.num < struct.num) {
            return "small";
        }
        if (this.num > struct.num) {
            return "big";
        }

        return null;
    }
}

public class Main {
    public static int partition(Struct[] stc, int low, int high) {
        if (low > high) {
            return -1;
        }
        //pivot就是基准位
        Struct pivot = stc[low];

        while (low < high) {
            //先看右边，依次往左递减
            while ((stc[high].compare(pivot).equals("big") || stc[high].compare(pivot).equals("equal")) && low < high) {
                high--;
            }
            stc[low] = stc[high];
            //再看左边，依次往右递增
            while ((stc[low].compare(pivot).equals("small") || stc[high].compare(pivot).equals("equal")) && low < high) {
                low++;
            }
            stc[high] = stc[low];
        }
        //最后将基准为与i和j相等位置的数字交换
        stc[low] = pivot;
        return low;
    }

    public static void quickSort(Struct[] stc, int low, int high) {
        if (low < high) {
            int pivotpos = partition(stc, low, high);
            //递归调用左半数组
            quickSort(stc, low, pivotpos - 1);
            //递归调用右半数组
            quickSort(stc, pivotpos + 1, high);
        }
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n, k;
        n = sc.nextInt();
        k = sc.nextInt();

        Struct[] stc = new Struct[k * 2];

        ArrayList<Integer> keyArray = new ArrayList<Integer>();
        keyArray.ensureCapacity(n);
        for (int i = 0; i < n; i++) {
            keyArray.add(i, i + 1);
        }

        for (int i = 0; i < k; i++) {
            int key, stime, duration;
            key = sc.nextInt();
            stime = sc.nextInt();
            duration = sc.nextInt();

            Struct s1 = new Struct(stime, 1, key, stime * 100 + 10 + key);
            Struct s0 = new Struct(stime + duration, 0, key, (stime + duration) * 100 + key);

            stc[i] = s1;
            stc[i + k] = s0;
        }

        quickSort(stc, 0, k * 2 - 1);

        for (int i = 0; i < k * 2; i++) {
            if (stc[i].getOper() == 1) {
                keyArray.set(keyArray.indexOf(stc[i].getKey()), 0);
            }
            if (stc[i].getOper() == 0) {
                keyArray.set(keyArray.indexOf(0), stc[i].getKey());
            }
        }

        for (int x : keyArray) {
            System.out.print(x + " ");
        }
    }
}
